﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.franchise.display {
    import flash.events.*;
    import flash.display.*;
    import Events.*;
    import org.aswing.*;
    import __AS3__.vec.*;
    import Display.*;
    import Modules.franchise.data.*;
    import Display.aswingui.*;

    public class FranchiseMenu extends Sprite {

        public static const STATUS_NEED_REFILL:String = "REFILL";
        public static const STATUS_WAITING:String = "WAIT";
        public static const STATUS_NEED_REMIND:String = "REMIND";
        public static const STATUS_DONE_REMIND:String = "DONE";
        public static const STATUS_ADD_NEIGHBOR:String = "ADD";
        public static const STATUS_COLLECT_WITHER:String = "WITHER";
        public static const STATUS_COLLECT_NOWITHER:String = "NOWITHER";
        public static const STATUS_BLANK:String = "BLANK";
        public static const STATUS_COLLECT_WAITING:String = "COLLECT_WAIT";
        public static const COLOR_MENU_STANDARD:uint = 10056537;
        public static const COLOR_MENU_GRAY:uint = 0x747474;
        public static const COLOR_MENU_GREEN:uint = 0xAA00;
        public static const COLOR_MENU_RED:uint = 0xFF6A00;

        public static var menuUI:FranchiseMenuUI;
        public static var selectedFranchise:OwnedFranchiseData;

        protected var m_content:JPanel = null;
        protected var m_holder:Sprite;

        public function FranchiseMenu(){
            var _local2:OwnedFranchiseData;
            super();
            var _local1:Vector.<OwnedFranchiseData> = Global.franchiseManager.getAllFranchises();
            for each (_local2 in _local1) {
                if (_local2.getLocationCount() > 0){
                    selectedFranchise = _local2;
                    break;
                };
            };
            this.loadAssets();
        }
        public static function get dailyCycleDelta():int{
            return (Math.floor(((Global.gameSettings.getNumber("dailyCollectCycleTimeSeconds") * Global.gameSettings.inGameDaySeconds) / 86400)));
        }

        protected function loadAssets():void{
            menuUI = new FranchiseMenuUI();
            this.m_content = menuUI;
            this.m_holder = new Sprite();
            this.addChild(this.m_holder);
            var _local1:JWindow = new JWindow(this.m_holder);
            _local1.setContentPane(menuUI);
            ASwingHelper.prepare(_local1);
            _local1.show();
            (this.m_content as FranchiseMenuUI).init(this, selectedFranchise);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
        }
        public function close():void{
            Global.ui.removeChild(this);
            dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
        }
        public function switchBusiness(_arg1:String):void{
            var _local2:FranchiseMenuUI = (this.m_content as FranchiseMenuUI);
            if (_local2){
                _local2.switchBusiness(_arg1);
            };
        }
        protected function onMouseOver(_arg1:MouseEvent):void{
            UI.setCursor(null);
            Global.ui.cleanUpToolTip();
        }

    }
}//package Modules.franchise.display 
